import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入字体图标库
import './assets/fonts/iconfont.css'
// 导入全局样式
import './assets/css/global.css'

import TableTree from 'vue-table-with-tree-grid'

// 导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'

import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

// 导入axios并挂载到Vue原型对象上
import axios from 'axios'
// 设置axios跟路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// axios请求拦截
axios.interceptors.request.use(config => {
  // 为请求头对象，添加Token验证的Authorization字段
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
Vue.prototype.$http = axios

// 我来搞一个全局变量放在原型对象上面
Vue.prototype.baseURL = 'http://127.0.0.1:8888/api/private/v1/'

Vue.config.productionTip = false

Vue.component('tree-table', TableTree)

Vue.use(VueQuillEditor)

// 搞一个时间过滤器
Vue.filter('dateFormat', function(t){
  const time = new Date(t)

  const y = time.getFullYear()
  const m = (time.getMonth()+'').padStart(2,'0')
  const d = (time.getDate()+'').padStart(2,'0')
  const h = (time.getHours()+'').padStart(2,'0')
  const fz = (time.getMinutes()+'').padStart(2,'0')
  const ss = (time.getSeconds()+'').padStart(2,'0')
  return `${y}-${m}-${d} ${h}:${fz}:${ss}`
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
